#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>

</style>
#end

#define content()
<div class="layui-fluid">
    <form id="searchForm" class="layui-form x-center" action="">
        <div class="layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">项目归属</label>
                <div class="layui-input-inline">
                    <select id='ownType' name="ownType" lay-filter="ownTypeSelect">
                        <option value="0" selected>我创建的</option>
                        <option value="1">我管理的</option>
                        <option value="2">我承接的</option>
                    </select>
                </div>
                <label class="layui-form-label" hidden>项目类型</label>
                <div class="layui-input-inline" hidden>
                    <select id='projectType' name="projectType">
                        <option></option>
                        #statusOption(PaTypeNameList)
                    </select>
                </div>
                <div class="layui-input-inline" style="width : 80px">
                    <button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i>
                    </button>
                </div>
            </div>
        </div>
    </form>
    <div class="layui-row">
        <table id="dateTable" lay-filter="dateTable"></table>
    </div>
</div>

<script type="text/html" id="riskTrack">
    #shiroHasPermission('/app/project/fileUploading')
    #[[
    {{#  if(d.ownType === 2){ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="toRisk">管理跟踪资料</a>
    #[[
    {{# } else{ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="toRisk">查看跟踪资料</a>
    #[[
    {{#  } }}
    ]]#
    #end
</script>
<script type="text/html" id="riskTrackEnd">
    #shiroHasPermission('/app/project/fileUploading')
    #[[
    {{#  if(d.ownType === 2 && !d.isUpload){ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="upLoad">上传跟踪移交表</a>
    #[[
    {{# } else if(d.ownType === 2 && d.isUpload){ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="seeFile">查看跟踪移交表</a>
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="upLoad">更新</a>
    #[[
    {{# } else if(d.ownType != 2 && d.isUpload){ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="seeFile">查看跟踪移交表</a>
    #[[
    {{# } else if(d.ownType != 2 && !d.isUpload){ }}
    ]]#
    <a class="layui-btn layui-btn-xs layui-btn-warm">暂无文件</a>
    #[[
    {{#  } }}
    ]]#
    #end
</script>
<script type="text/html" id="barOption">
    #shiroHasPermission('/app/project/see')
    <a class="layui-btn layui-btn-xs" lay-event="see">查看项目详情</a>
    #end
</script>
#end

#define js()
<script type="text/javascript">
    var own = 0;
    layui.use(['table', 'layer','form'], function () {
        var table = layui.table
            , form = layui.form;
        var url = "#(url)";
        var riskFileTypeID = "#(riskFileTypeID)"
        // 表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , id: 'dateTable'
            , even: true //开启隔行背景
            , size: 'sm' //小尺寸的表格
            , height: 'full-100'    //容器高度
            , contentType: 'application/json; charset=UTF-8'
            , cols: [[                  //标题栏
                {type: 'numbers', fixed: true, unresize: 'true'}
                , {field: 'name', title: '名称', minWidth: 100, sort: true}
                , {field: 'projectAssTypeName', title: '类型', width: 150, sort: true}
                , {field: 'amount', title: '预计金额(单位：元)', width: 130, sort: true, templet: '#tplMoney'}
                , {field: 'assessmentMode', title: '评估方式', width: 100, sort: true}
                , {field: 'status', title: '状态', width: 100, sort: true,
                    templet: '#statusTpl(io.jboot.admin.service.entity.status.system.ProjectStatus::me(), "status")'}
                , {field: 'createTime', title: '创建时间', width: 150, sort: true}
                , {title: '进程跟踪', width: 150, align: 'center', toolbar: '#riskTrack'}
                , {title: '跟踪移交', width: 200, align: 'center', toolbar: '#riskTrackEnd'}
                , {fixed: 'right', title: '操作', width: 120, align: 'center', toolbar: '#barOption'} //这里的toolbar值是模板元素的选择器
            ]]
            , where: {
                ownType:0
            }
            , url: '#(ctxPath)/app/track/projectRiskListTableData'
            , method: 'get'
            , request: {
                pageName: 'pageNumber' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , page: true
            , limits: [30, 60, 90, 150, 300]
            , limit: 30 //默认采用30
            , loading: true
            , done: function (res, curr, count) {
            }
        });
        table.on('tool(dateTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'toRisk') {
                //进入上传跟踪管理登记表界面
                window.location.href = '#(ctxPath)/app/track/toRiskTrackManagement?projectID=' + data.id;
            } else if (obj.event === 'upLoad') {
                pop_show('上传跟踪资料移交表', '#(ctxPath)/app/project/fileUploading?id=' + riskFileTypeID + '&projectId=' + data.id, '500', '300', function () {
                    reloadTable("", own);
                });
            } else if (obj.event === 'seeFile') {
                pop_show('查看跟踪资料移交表', '#(ctxPath)/util/pdfView?fileID=' + data.fileID, '', '', function () {
                    reloadTable("", own);
                });
            } else if (obj.event === 'see') {
                pop_show('查看项目资料', '#(ctxPath)/app/project/see?id=' + data.id, '1200', '750', function () {
                    reloadTable("", own);
                });
            }
        });

        reloadTable = function (projectType, ownType) {
            table.reload('dateTable', {
                url: '#(ctxPath)/app/track/projectRiskListTableData?projectType=' + projectType + '&ownType=' + ownType
            });
        };
        form.on('submit(search)', function (data) {
            reloadTable(data.field.projectType, data.field.ownType);
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('select(ownTypeSelect)', function(data){
            own = data.value;
            reloadTable($('#projectType').val(), own);
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>

<script type="text/html" id="tplMoney">{{formatCurrency(d.amount)}}</script>
#end
